Ext.onReady(function () {
    Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
    columns = [
        { id: 'name', header: 'Name', dataIndex: 'name__c', width: 100 },
        { header: 'Active', dataIndex: 'active', type: 'boolean' },
        { header: 'Start Date', dataIndex: 'startdate', xtype: 'datecolumn' },
        { header: 'End Date', dataIndex: 'enddate', xtype: 'datecolumn' },
        { header: 'Release', dataIndex: 'release__c', type: 'combo' },
        { header: 'Product', dataIndex: 'product__c', type: 'combo' },
        { header: 'Description', dataIndex: 'desc', width: 220 }
    ];
    var recordType = [
        { name: 'id__c', mapping: 'id__c', type: 'int' },
        { name: 'name__c', mapping: 'name__c', type: 'string' },
        { name: 'active', mapping: 'active', type: 'boolean' },
        { name: 'startdate', mapping: 'startdate', type: 'date' },
        { name: 'enddate', mapping: 'enddate', type: 'date' },
        { name: 'release__c', mapping: 'release__c.display', type: 'string' },
        { name: 'product__c', mapping: 'product__c.display', type: 'string' },
        { name: 'desc', mapping: 'desc', type: 'string' },
        { name: 'objecttype', mapping: 'objecttype', type: 'string' }
    ];
    api = {
        read : 'Sprint.aspx?action=read', 
        create : 'Sprint.aspx?action=create',
        update  : 'Sprint.aspx?action=update', 
        destroy : 'Sprint.aspx?action=destroy',
    };
    var formConfig = { title: 'New Sprint',
        items: [{ fieldLabel: 'First Name', name: 'first', allowBlank: false },
            { fieldLabel: 'Last Name', name: 'last' },
            { fieldLabel: 'Company', name: 'company' },
            { fieldLabel: 'Email', name: 'email', vtype: 'email' },
            new Ext.form.TimeField({ fieldLabel: 'Time', name: 'time', minValue: '8:00am', maxValue: '6:00pm' })
        ]
    }
    var gridPanel = new ScrumEditorGridPanel({ id: 'grid-panel',
        storeConfig: {groupField: 'release__c', proxyConfig: {api: api}, readerConfig: {recordType: recordType}, writerConfig: {api: api}},
        cmConfig: { columns: columns },
        newPwConfig: { formConfig: formConfig }
    });
    var viewport = new DefaultScrumViewport({
        center: { title: 'Sprint List', gridPanel: gridPanel }
    });
});
